home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / whatview / wvprefs.e < prev    next >
Text File  |  1994-05-02  |  27KB  |  668 lines

  1. /*******************************************************************************************/
  2. /* Source code generate by Gui2E v0.1 © 1994 NasGûl                                        */
  3. /*******************************************************************************************/
  4. /********************************************************************************
  5.  * << EUTILS HEADER >>
  6.  ********************************************************************************
  7.  ED
  8.  EC
  9.  PREPRO
  10.  SOURCE
  11.  EPPDEST
  12.  EXEC
  13.  ISOURCE
  14.  HSOURCE
  15.  ERROREC
  16.  ERROREPP
  17.  VERSION
  18.  REVISION
  19.  NAMEPRG
  20.  NAMEAUTHOR
  21.  ********************************************************************************
  22.  * HISTORY :
  23.  *******************************************************************************/
  24.  
  25. OPT OSVERSION=37
  26.  
  27. MODULE 'intuition/intuition','gadtools','libraries/gadtools','intuition/gadgetclass','intuition/screens',
  28.        'graphics/text','exec/lists','exec/nodes','exec/ports','eropenlib','utility/tagitem'
  29. MODULE 'whatis','wvprefs'
  30. MODULE 'asl','libraries/asl'
  31. ENUM ER_NONE,ER_LOCKSCREEN,ER_VISUAL,ER_CONTEXT,ER_MENUS,ER_GADGET,ER_WINDOW,
  32.      ER_MEM
  33. RAISE ER_MEM IF New()=NIL,
  34.       ER_MEM IF String()=NIL
  35.  
  36. CONST LOAD_PREFS=0,
  37.       SAVE_PREFS=1
  38.  
  39. DEF screen:PTR TO screen,
  40.     visual=NIL,
  41.     tattr:PTR TO textattr,
  42.     reelquit=FALSE,
  43.     offy
  44. /****************************************
  45.  * wp Definitions
  46.  ****************************************/
  47. DEF wp_window=NIL:PTR TO window
  48. DEF wp_glist=NIL
  49. /* Gadgets */
  50. ENUM GA_G_COMMAND,GA_G_GETCOMMAND,GA_G_EXECTYPE,
  51.      GA_G_STACK,GA_G_PRI,GA_G_LOAD,GA_G_SAVE,
  52.      GA_G_SAVEAS,GA_G_ADD,GA_G_REM,GA_G_IDLIST,
  53.      GA_G_ACTIONLIST
  54. /* Gadgets labels of wp */
  55. DEF g_command,g_getcommand,g_exectype,
  56.     g_stack,g_pri,g_load,g_save,g_saveas,
  57.     g_add,g_rem,g_idlist,g_actionlist
  58. /* Application def       */
  59. DEF mywvbase:PTR TO wvbase
  60. DEF curidnode=0
  61. DEF curactionnode=0
  62. DEF defdir[256]:STRING
  63. /***************************/
  64. /* OpenClose Libraries     */
  65. /***************************/
  66. PROC p_OpenLibraries() HANDLE /*"p_OpenLibraries()"*/
  67.     IF (intuitionbase:=OpenLibrary('intuition.library',37))=NIL THEN Raise(ER_INTUITIONLIB)
  68.     IF (gadtoolsbase:=OpenLibrary('gadtools.library',37))=NIL THEN Raise(ER_GADTOOLSLIB)
  69.     IF (gfxbase:=OpenLibrary('graphics.library',37))=NIL THEN Raise(ER_GRAPHICSLIB)
  70.     IF (whatisbase:=OpenLibrary('whatis.library',3))=NIL THEN Raise(ER_WHATISLIB)
  71.     IF (aslbase:=OpenLibrary('asl.library',37))=NIL THEN Raise(ER_ASLLIB)
  72.     Raise(ER_NONE)
  73. EXCEPT
  74.     RETURN exception
  75. ENDPROC
  76. PROC p_CloseLibraries()  /*"p_CloseLibraries()"*/
  77.     IF aslbase THEN CloseLibrary(aslbase)
  78.     IF whatisbase THEN CloseLibrary(whatisbase)
  79.     IF gfxbase THEN CloseLibrary(gfxbase)
  80.     IF gadtoolsbase THEN CloseLibrary(gadtoolsbase)
  81.     IF intuitionbase THEN CloseLibrary(intuitionbase)
  82. ENDPROC
  83. /***************************/
  84. /* Gestion de la liste     */
  85. /***************************/
  86. PROC p_InitList() HANDLE /*"p_InitList()"*/
  87. /********************************************************************************
  88.  * Para         : NONE
  89.  * Return       : address of the new list if ok,else NIL.
  90.  * Description  : Initialise a list.
  91.  *******************************************************************************/
  92.     DEF i_list:PTR TO lh
  93.     i_list:=New(SIZEOF lh)
  94.     i_list.tail:=0
  95.     i_list.head:=i_list.tail
  96.     i_list.tailpred:=i_list.head
  97.     i_list.type:=0
  98.     i_list.pad:=0
  99.     IF i_list THEN Raise(i_list) ELSE Raise(NIL)
  100. EXCEPT
  101.     RETURN exception
  102. ENDPROC
  103. PROC p_RemoveList(ptr_list) /*"p_RemoveList(ptr_list)"*/
  104. /********************************************************************************
  105.  * Para         : address of list
  106.  * Return       : NONE
  107.  * Description  : p_CleanList() and dispose the list.
  108.  *******************************************************************************/
  109.     DEF r_list:PTR TO lh
  110.     r_list:=p_CleanList(ptr_list)
  111.     IF r_list THEN Dispose(r_list)
  112. ENDPROC
  113. PROC p_CleanList(ptr_list) /*"p_CleanList(ptr_list)"*/
  114. /********************************************************************************
  115.  * Para         : address of list
  116.  * Return       : address of clean list
  117.  * Description  : Remove all nodes in the list.
  118.  *******************************************************************************/
  119.     DEF c_node:PTR TO ln
  120.     DEF c_list:PTR TO lh
  121.     c_list:=ptr_list
  122.     c_node:=c_list.head
  123.     WHILE c_node
  124.         IF c_node.succ
  125.             IF c_node.succ=0 THEN RemTail(c_list)
  126.             IF c_node.pred=0 THEN RemHead(c_list)
  127.             IF (c_node.succ<>0) AND (c_node.pred<>0) THEN Remove(c_node)
  128.         ENDIF
  129.         c_node:=c_node.succ
  130.     ENDWHILE
  131.     RETURN c_list
  132. ENDPROC
  133. PROC p_GetAdrNode(ptr_list,num_node) /*"p_GetAdrNode(ptr_list,num_node)"*/
  134. /********************************************************************************
  135.  * Para         : address of list,number's node.
  136.  * Return       : address of node or NIL.
  137.  * Description  : Find the address of a node.
  138.  *******************************************************************************/
  139.     DEF g_list:PTR TO lh
  140.     DEF g_node:PTR TO ln
  141.     DEF count=0
  142.     g_list:=ptr_list
  143.     g_node:=g_list.head
  144.     WHILE g_node
  145.         IF count=num_node THEN RETURN g_node
  146.         INC count
  147.         g_node:=g_node.succ
  148.     ENDWHILE
  149.     RETURN NIL
  150. ENDPROC
  151. PROC p_GetNumNode(ptr_list,adr_node) /*"p_GetNumNode(ptr_list,adr_node)"*/
  152. /********************************************************************************
  153.  * Para         : address of list,address of node
  154.  * Return       : the number of the node.
  155.  * Description  : Find the number of a node.
  156.  *******************************************************************************/
  157.     DEF g_list:PTR TO lh
  158.     DEF g_node:PTR TO ln
  159.     DEF count=0
  160.     g_list:=ptr_list
  161.     g_node:=g_list.head
  162.     WHILE g_node
  163.         IF g_node=adr_node THEN RETURN count
  164.         INC count
  165.         g_node:=g_node.succ
  166.     ENDWHILE
  167.     RETURN NIL
  168. ENDPROC
  169. PROC p_AjouteNode(ptr_list,node_name) HANDLE /*"p_AjouteNode(ptr_list,node_name)"*/
  170. /********************************************************************************
  171.  * Para         : address of list,the name of a node.
  172.  * Return       : the number of the new selected node in the list.
  173.  * Description  : Add a node and return the new current node (for LISTVIEW_KIND).
  174.  *******************************************************************************/
  175.     DEF a_list:PTR TO lh
  176.     DEF a_node:PTR TO ln
  177.     DEF nn=NIL
  178.     a_list:=ptr_list
  179.     a_node:=New(SIZEOF ln)
  180.     a_node.succ:=0
  181.     a_node.name:=String(EstrLen(node_name))
  182.     StrCopy(a_node.name,node_name,ALL)
  183.     AddTail(a_list,a_node)
  184.     nn:=p_GetNumNode(a_list,a_node)
  185.     IF nn=0
  186.         a_list.head:=a_node
  187.         a_node.pred:=0
  188.    /**********************************************
  189.         a_node.succ:=0
  190.         a_list.tailpred:=a_node
  191.     ELSE
  192.         a_node.succ:=0
  193.         a_node.pred:=p_GetAdrNode(a_list,nn-1)
  194.         a_list.tailpred:=a_node
  195.     **********************************************/
  196.     ENDIF
  197.     Raise(nn)
  198. EXCEPT
  199.     RETURN exception
  200. ENDPROC
  201. PROC p_EmptyList(adr_list) /*"p_EmptyList(adr_list)"*/
  202. /********************************************************************************
  203.  * Para         : address of list.
  204.  * Return       : TRUE if list is empty,else address of list.
  205.  * Description  : Look if a list is empty.
  206.  *******************************************************************************/
  207.     DEF e_list:PTR TO lh,count=0
  208.     DEF e_node:PTR TO ln
  209.     e_list:=adr_list
  210.     e_node:=e_list.head
  211.     WHILE e_node
  212.         IF e_node.succ<>0 THEN INC count
  213.         e_node:=e_node.succ
  214.     ENDWHILE
  215.     IF count=0 THEN RETURN TRUE ELSE RETURN e_list
  216. ENDPROC
  217. /******************************************/
  218. PROC p_AjouteActionNode(numid,list:PTR TO lh) /*"p_AjouteActionNode(numid,list:PTR TO lh)"*/
  219.     DEF idnode:PTR TO ln
  220.     DEF node:PTR TO ln
  221.     DEF myactnode:PTR TO actionnode,nn
  222.     idnode:=p_GetAdrNode(mywvbase.adridlist,numid)
  223.     IF FindName(mywvbase.adractionlist,idnode.name)
  224.         EasyRequestArgs(0,[20,0,0,'Le Type "\s" existe déjà.','Ok'],0,[idnode.name])
  225.         RETURN FALSE
  226.     ENDIF
  227.     node:=New(SIZEOF ln)
  228.     myactnode:=New(SIZEOF actionnode)
  229.     node.succ:=0
  230.     node.name:=String(EstrLen(idnode.name))
  231.     StrCopy(node.name,idnode.name,ALL)
  232.     CopyMem(node,myactnode.node,SIZEOF ln)
  233.     AddTail(mywvbase.adractionlist,myactnode.node)
  234.     nn:=p_GetNumNode(mywvbase.adractionlist,myactnode.node)
  235.     curactionnode:=nn
  236.     IF nn=0
  237.         list.head:=myactnode.node
  238.         node.pred:=0
  239.     ENDIF
  240.     myactnode.exectype:=MODE_WB
  241.     myactnode.command:=0
  242.     myactnode.currentdir:=0
  243.     myactnode.stack:=4000
  244.     myactnode.priority:=0
  245.     IF node THEN Dispose(node)
  246. ENDPROC
  247. PROC p_EnleveActionNode(list:PTR TO lh,numnode) /*"p_EnleveActionNode(list:PTR TO lh,numnode)"*/
  248.     DEF eactnode:PTR TO actionnode
  249.     DEF node:PTR TO ln
  250.     DEF count=0,retour=NIL
  251.     DEF newn:PTR TO ln
  252.     eactnode:=list.head
  253.     WHILE eactnode
  254.         node:=eactnode
  255.         IF count=numnode
  256.             IF node.succ<>0
  257.                 IF node.name THEN Dispose(node.name)
  258.                 IF eactnode.command THEN Dispose(eactnode.command)
  259.                 IF eactnode.currentdir THEN Dispose(eactnode.currentdir)
  260.                 IF eactnode THEN Dispose(eactnode)
  261.             ENDIF
  262.             IF node.succ=0
  263.                 RemTail(list)
  264.                 retour:=numnode-1
  265.             ELSEIF node.pred=0
  266.                 RemHead(list)
  267.                 retour:=numnode
  268.                 newn:=p_GetAdrNode(list,numnode)
  269.                 list.head:=newn
  270.                 newn.pred:=0
  271.             ELSEIF (node.succ<>0) AND (node.pred<>0)
  272.                 Remove(node)
  273.                 retour:=numnode-1
  274.             ENDIF
  275.         ENDIF
  276.         INC count
  277.         eactnode:=node.succ
  278.     ENDWHILE
  279.     RETURN retour
  280. ENDPROC
  281. PROC p_CleanActionList(list:PTR TO lh) /*"p_CleanActionList(list:PTR TO lh)"*/
  282.     DEF eactnode:PTR TO actionnode
  283.     DEF node:PTR TO ln
  284.     eactnode:=list.head
  285.     WHILE eactnode
  286.         node:=eactnode
  287.         IF node.succ<>0
  288.             IF node.name THEN Dispose(node.name)
  289.             IF eactnode.command THEN Dispose(eactnode.command)
  290.             IF eactnode.currentdir THEN Dispose(eactnode.currentdir)
  291.             IF eactnode THEN Dispose(eactnode)
  292.         ENDIF
  293.         IF node.succ=0
  294.             RemTail(list)
  295.         ELSEIF node.pred=0
  296.             RemHead(list)
  297.         ELSEIF (node.succ<>0) AND (node.pred<>0)
  298.             Remove(node)
  299.         ENDIF
  300.         eactnode:=node.succ
  301.     ENDWHILE
  302. ENDPROC
  303. PROC p_RemoveActionList(list:PTR TO lh,mode) /*"p_RemoveActionList(list:PTR TO lh,mode)"*/
  304.     p_CleanActionList(list)
  305.     IF mode=TRUE
  306.         IF list THEN Dispose(list)
  307.     ENDIF
  308. ENDPROC
  309. /***************************/
  310. /* Window Proc             */
  311. /***************************/
  312. PROC p_SetUpScreen() HANDLE /*"p_SetUpScreen()"*/
  313.     IF (screen:=LockPubScreen('Workbench'))=NIL THEN Raise(ER_LOCKSCREEN)
  314.     IF (visual:=GetVisualInfoA(screen,NIL))=NIL THEN Raise(ER_VISUAL)
  315.     offy:=screen.wbortop+Int(screen.rastport+58)+1
  316.     Raise(ER_NONE)
  317. EXCEPT
  318.     RETURN exception
  319. ENDPROC
  320. PROC p_SetDownScreen() /*"p_SetDownScreen()"*/
  321.     IF visual THEN FreeVisualInfo(visual)
  322.     IF screen THEN UnlockPubScreen(NIL,screen)
  323. ENDPROC
  324. PROC p_InitwpWindow() HANDLE /*"p_InitwpWindow()"*/
  325.     IF (wp_glist:=CreateContext({wp_glist}))=NIL THEN Raise(ER_CONTEXT)
  326.     IF (g_command:=CreateGadgetA(TEXT_KIND,wp_glist,[88,19,181,12,'Commande',tattr,0,1,visual,0]:newgadget,[GTTX_BORDER,TRUE,GTTX_TEXT,'',GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  327.     IF (g_getcommand:=CreateGadgetA(BUTTON_KIND,g_command,[269,19,41,12,'?',tattr,1,16,visual,0]:newgadget,[GA_RELVERIFY,TRUE,GA_DISABLED,FALSE,GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  328.     IF (g_exectype:=CreateGadgetA(CYCLE_KIND,g_getcommand,[88,32,221,12,'ExecType',tattr,2,1,visual,0]:newgadget,[GA_RELVERIFY,TRUE,GTCY_LABELS,['Mode WB','Mode CLI',0],GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  329.     IF (g_stack:=CreateGadgetA(INTEGER_KIND,g_exectype,[218,45,91,12,'Pile',tattr,3,1,visual,0]:newgadget,[GTIN_NUMBER,NIL,GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  330.     IF (g_pri:=CreateGadgetA(INTEGER_KIND,g_stack,[88,45,77,12,'Priorité',tattr,4,1,visual,0]:newgadget,[GTIN_NUMBER,NIL,GA_RELVERIFY,TRUE,GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  331.     IF (g_load:=CreateGadgetA(BUTTON_KIND,g_pri,[16,63,81,12,'_Charger',tattr,5,16,visual,0]:newgadget,[GA_RELVERIFY,TRUE,GA_DISABLED,FALSE,GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  332.     IF (g_save:=CreateGadgetA(BUTTON_KIND,g_load,[122,63,81,12,'_Sauver',tattr,6,16,visual,0]:newgadget,[GA_RELVERIFY,TRUE,GA_DISABLED,FALSE,GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  333.     IF (g_saveas:=CreateGadgetA(BUTTON_KIND,g_save,[229,63,81,12,'S_auver S.',tattr,7,16,visual,0]:newgadget,[GA_RELVERIFY,TRUE,GA_DISABLED,FALSE,GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  334.     IF (g_add:=CreateGadgetA(BUTTON_KIND,g_saveas,[56,81,81,12,'_Add',tattr,8,16,visual,0]:newgadget,[GA_RELVERIFY,TRUE,GA_DISABLED,FALSE,GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  335.     IF (g_rem:=CreateGadgetA(BUTTON_KIND,g_add,[188,81,81,12,'_Rem',tattr,9,16,visual,0]:newgadget,[GA_RELVERIFY,TRUE,GA_DISABLED,FALSE,GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  336.     IF (g_idlist:=CreateGadgetA(LISTVIEW_KIND,g_rem,[28,106,110,41,'ID',tattr,10,4,visual,0]:newgadget,[GTLV_SHOWSELECTED,NIL,GTLV_LABELS,-1,GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  337.     IF (g_actionlist:=CreateGadgetA(LISTVIEW_KIND,g_idlist,[176,106,110,41,'Action',tattr,11,4,visual,0]:newgadget,[GTLV_SHOWSELECTED,NIL,GTLV_LABELS,-1,GT_UNDERSCORE,"_",TAG_DONE,0]))=NIL THEN Raise(ER_GADGET)
  338.     Raise(ER_NONE)
  339. EXCEPT
  340.     RETURN exception
  341. ENDPROC
  342. PROC p_RenderwpWindow() /*"p_RenderwpWindow()"*/
  343.     DEF infonode:PTR TO actionnode
  344.     IF p_EmptyList(mywvbase.adractionlist)<>-1
  345.         infonode:=p_GetAdrNode(mywvbase.adractionlist,curactionnode)
  346.         Gt_SetGadgetAttrsA(g_command,wp_window,NIL,[GA_DISABLED,FALSE,GTTX_BORDER,TRUE,GTTX_TEXT,infonode.command,TAG_DONE,0])
  347.         Gt_SetGadgetAttrsA(g_getcommand,wp_window,NIL,[GA_DISABLED,FALSE,TAG_DONE,0])
  348.         Gt_SetGadgetAttrsA(g_exectype,wp_window,NIL,[GA_DISABLED,FALSE,GTCY_ACTIVE,infonode.exectype,TAG_DONE,0])
  349.         Gt_SetGadgetAttrsA(g_stack,wp_window,NIL,[GA_DISABLED,FALSE,GTIN_NUMBER,infonode.stack,TAG_DONE,0])
  350.         Gt_SetGadgetAttrsA(g_pri,wp_window,NIL,[GA_DISABLED,FALSE,GTIN_NUMBER,infonode.priority,TAG_DONE,0])
  351.         Gt_SetGadgetAttrsA(g_actionlist,wp_window,NIL,[GA_DISABLED,FALSE,GTLV_SHOWSELECTED,TRUE,GTLV_SELECTED,curactionnode,GTLV_LABELS,mywvbase.adractionlist,TAG_DONE,0])
  352.         Gt_SetGadgetAttrsA(g_rem,wp_window,NIL,[GA_DISABLED,FALSE,TAG_DONE,0])
  353.     ELSE
  354.         Gt_SetGadgetAttrsA(g_command,wp_window,NIL,[GA_DISABLED,TRUE,GTTX_BORDER,TRUE,GTTX_TEXT,'',TAG_DONE,0])
  355.         Gt_SetGadgetAttrsA(g_getcommand,wp_window,NIL,[GA_DISABLED,TRUE,TAG_DONE,0])
  356.         Gt_SetGadgetAttrsA(g_exectype,wp_window,NIL,[GA_DISABLED,TRUE,TAG_DONE,0])
  357.         Gt_SetGadgetAttrsA(g_stack,wp_window,NIL,[GA_DISABLED,TRUE,GTIN_NUMBER,NIL,TAG_DONE,0])
  358.         Gt_SetGadgetAttrsA(g_pri,wp_window,NIL,[GA_DISABLED,TRUE,GTIN_NUMBER,NIL,TAG_DONE,0])
  359.         Gt_SetGadgetAttrsA(g_actionlist,wp_window,NIL,[GA_DISABLED,TRUE,GTLV_SHOWSELECTED,NIL,GTLV_LABELS,mywvbase.adremptylist,TAG_DONE,0])
  360.         Gt_SetGadgetAttrsA(g_rem,wp_window,NIL,[GA_DISABLED,TRUE,TAG_DONE,0])
  361.     ENDIF
  362.     Gt_SetGadgetAttrsA(g_idlist,wp_window,NIL,[GTLV_SHOWSELECTED,TRUE,GTLV_SELECTED,curidnode,GTLV_TOP,curidnode,GTLV_LABELS,mywvbase.adridlist,TAG_DONE,0])
  363.     DrawBevelBoxA(wp_window.rport,9,61,305,16,[GT_VISUALINFO,visual,TAG_DONE,0])
  364.     DrawBevelBoxA(wp_window.rport,9,13,305,46,[GT_VISUALINFO,visual,TAG_DONE,0])
  365.     DrawBevelBoxA(wp_window.rport,9,79,304,68,[GT_VISUALINFO,visual,TAG_DONE,0])
  366.     RefreshGList(g_command,wp_window,NIL,-1)
  367.     Gt_RefreshWindow(wp_window,NIL)
  368. ENDPROC
  369. PROC p_OpenwpWindow() HANDLE /*"p_OpenwpWindow()"*/
  370.     IF (wp_window:=OpenWindowTagList(NIL,
  371.                       [WA_LEFT,10,
  372.                        WA_TOP,10,
  373.                        WA_WIDTH,319,
  374.                        WA_HEIGHT,150,
  375.                        WA_IDCMP,$400278,
  376.                        WA_FLAGS,$102E,
  377.                        WA_GADGETS,wp_glist,
  378.                        WA_TITLE,'WVPrefs v0.1 © NasGûl',
  379.                        WA_SCREENTITLE,'Made With GadToolsBox v2.0 © 1991-1993',
  380.                        TAG_DONE]))=NIL THEN Raise(ER_WINDOW)
  381.     p_RenderwpWindow()
  382.     Raise(ER_NONE)
  383. EXCEPT
  384.     RETURN exception
  385. ENDPROC
  386. PROC p_RemwpWindow() /*"p_RemwpWindow()"*/
  387.     IF wp_window THEN CloseWindow(wp_window)
  388.     IF wp_glist THEN FreeGadgets(wp_glist)
  389. ENDPROC
  390. PROC p_LockListView() /*"p_LockListView()"*/
  391.     Gt_SetGadgetAttrsA(g_actionlist,wp_window,NIL,[GTLV_LABELS,-1,TAG_DONE,0])
  392. ENDPROC
  393. /***************************/
  394. /* Message proc            */
  395. /***************************/
  396. PROC p_LookAllMessage() /*"p_LookAllMessage()"*/
  397.     DEF sigreturn
  398.     DEF wpport:PTR TO mp
  399.     IF wp_window THEN wpport:=wp_window.userport ELSE wpport:=NIL
  400.     sigreturn:=Wait(Shl(1,wpport.sigbit) OR
  401.                     $F000)
  402.     IF (sigreturn AND Shl(1,wpport.sigbit))
  403.         p_LookwpMessage()
  404.     ENDIF
  405.     IF (sigreturn AND $F000)
  406.         reelquit:=TRUE
  407.     ENDIF
  408. ENDPROC
  409. PROC p_LookwpMessage() /*"p_LookwpMessage()"*/
  410.    DEF mes:PTR TO intuimessage
  411.    DEF g:PTR TO gadget
  412.    DEF gstr:PTR TO stringinfo
  413.    DEF type=0,infos=NIL
  414.    DEF actnode:PTR TO actionnode
  415.    WHILE (mes:=Gt_GetIMsg(wp_window.userport))
  416.        type:=mes.class
  417.        SELECT type
  418.            CASE IDCMP_MENUPICK
  419.               infos:=mes.code
  420.               SELECT infos
  421.               ENDSELECT
  422.            CASE IDCMP_CLOSEWINDOW
  423.               reelquit:=TRUE
  424.            CASE IDCMP_GADGETDOWN
  425.               type:=IDCMP_GADGETUP
  426.            CASE IDCMP_GADGETUP
  427.               g:=mes.iaddress
  428.               infos:=g.gadgetid
  429.               SELECT infos
  430.                   CASE GA_G_COMMAND
  431.                   CASE GA_G_GETCOMMAND
  432.                       p_LockListView()
  433.                       p_FileRequester(curactionnode,NIL)
  434.                       p_RenderwpWindow()
  435.                   CASE GA_G_EXECTYPE
  436.                       actnode:=p_GetAdrNode(mywvbase.adractionlist,curactionnode)
  437.                       actnode.exectype:=mes.code
  438.                   CASE GA_G_STACK
  439.                       gstr:=g.specialinfo
  440.                       actnode:=p_GetAdrNode(mywvbase.adractionlist,curactionnode)
  441.                       actnode.stack:=Val(gstr.buffer,NIL)
  442.                   CASE GA_G_PRI
  443.                       gstr:=g.specialinfo
  444.                       actnode:=p_GetAdrNode(mywvbase.adractionlist,curactionnode)
  445.                       actnode.stack:=Val(gstr.buffer,NIL)
  446.                   CASE GA_G_LOAD
  447.                       p_LockListView()
  448.                       p_FileRequester(-1,LOAD_PREFS)
  449.                       p_RenderwpWindow()
  450.                   CASE GA_G_SAVE
  451.                       p_LockListView()
  452.                       p_SavePrefsFile(mywvbase.adractionlist,'Env:WhatView.Prefs')
  453.                       p_RenderwpWindow()
  454.                   CASE GA_G_SAVEAS
  455.                       p_LockListView()
  456.                       p_FileRequester(-1,SAVE_PREFS)
  457.                       p_RenderwpWindow()
  458.                   CASE GA_G_ADD
  459.                       p_LockListView()
  460.                       p_AjouteActionNode(curidnode,mywvbase.adractionlist)
  461.                       p_RenderwpWindow()
  462.                   CASE GA_G_REM
  463.                       p_LockListView()
  464.                       curactionnode:=p_EnleveActionNode(mywvbase.adractionlist,curactionnode)
  465.                       p_RenderwpWindow()
  466.                   CASE GA_G_IDLIST
  467.                       curidnode:=mes.code
  468.                   CASE GA_G_ACTIONLIST
  469.                       curactionnode:=mes.code
  470.                       p_RenderwpWindow()
  471.               ENDSELECT
  472.        ENDSELECT
  473.        Gt_ReplyIMsg(mes)
  474.    ENDWHILE
  475. ENDPROC
  476. /***************************/
  477. /* Application proc        */
  478. /***************************/
  479. PROC p_InitWVAPP() HANDLE /*"p_InitWVAPP()"*/
  480.     mywvbase:=New(SIZEOF wvbase)
  481.     mywvbase.adridlist:=p_InitList()
  482.     mywvbase.adractionlist:=p_InitList()
  483.     mywvbase.adremptylist:=p_InitList()
  484.     p_AjouteNode(mywvbase.adremptylist,'')
  485.     Raise(p_BuildIdList())
  486.     Raise(ER_NONE)
  487. EXCEPT
  488.     RETURN exception
  489. ENDPROC
  490. PROC p_RemWVAPP() /*"p_RemWVAPP()"*/
  491.     IF mywvbase.adridlist THEN p_RemoveList(mywvbase.adridlist)
  492.     IF mywvbase.adremptylist THEN p_RemoveList(mywvbase.adremptylist)
  493.     IF mywvbase.adractionlist THEN p_RemoveActionList(mywvbase.adractionlist,TRUE)
  494.     IF mywvbase THEN Dispose(mywvbase)
  495. ENDPROC
  496. PROC p_BuildIdList() /*"p_BuildIdList()"*/
  497. /********************************************************************************
  498.  * Para         : NONE
  499.  * Return       : NONE
  500.  * Description  : Clean the ListView and rebuild it with all filetype (whatis.library).
  501.  *******************************************************************************/
  502.     DEF next
  503.     DEF id_str[9]:STRING
  504.     DEF my_string[256]:STRING
  505.     p_CleanList(mywvbase.adridlist)
  506.     next:=FirstType()
  507.     WHILE next
  508.         id_str:=GetIDString(next)
  509.         StringF(my_string,'\s',id_str)
  510.         p_AjouteNode(mywvbase.adridlist,my_string)
  511.         next:=NextType(next)
  512.     ENDWHILE
  513.     RETURN ER_NONE
  514. ENDPROC
  515. PROC p_FileRequester(numactnode,action) /*"p_FileRequester(numactnode,action)"*/
  516.   DEF fichier[256]:STRING
  517.   DEF dossier[256]:STRING
  518.   DEF piv_string[256]:STRING
  519.   DEF reqload:PTR TO filerequestr
  520.   DEF mnode:PTR TO actionnode
  521.   IF reqload:=AllocAslRequest(ASL_FILEREQUEST,[ASL_OKTEXT,'Ok',ASL_DIR,defdir,0])
  522.       IF RequestFile(reqload)
  523.           StringF(dossier,'\s',reqload.dir)
  524.           StringF(defdir,'\s',reqload.dir)
  525.           StringF(fichier,'\s',reqload.file)
  526.       ELSE
  527.       ENDIF
  528.       FreeAslRequest(reqload)
  529.   ELSE
  530.      RETURN FALSE
  531.   ENDIF
  532.   IF numactnode<>-1
  533.       mnode:=p_GetAdrNode(mywvbase.adractionlist,numactnode)
  534.       IF mnode.command THEN DisposeLink(mnode.command)
  535.       mnode.command:=String(EstrLen(fichier))
  536.       StrCopy(mnode.command,fichier,ALL)
  537.       IF mnode.currentdir THEN DisposeLink(mnode.currentdir)
  538.       mnode.currentdir:=String(EstrLen(dossier))
  539.       StrCopy(mnode.currentdir,dossier,ALL)
  540.   ELSE
  541.       SELECT action
  542.         CASE LOAD_PREFS
  543.           AddPart(dossier,'',256)
  544.           StringF(piv_string,'\s\s',dossier,fichier)
  545.           p_ReadPrefsFile(piv_string)
  546.         CASE SAVE_PREFS
  547.           AddPart(dossier,'',256)
  548.           StringF(piv_string,'\s\s',dossier,fichier)
  549.           p_SavePrefsFile(mywvbase.adractionlist,piv_string)
  550.       ENDSELECT
  551.   ENDIF
  552. ENDPROC
  553. PROC p_SavePrefsFile(list:PTR TO lh,fichier) /*"p_SavePrefsFile(list:PTR TO lh,fichier)"*/
  554.     DEF sactnode:PTR TO actionnode
  555.     DEF node:PTR TO ln
  556.     DEF h
  557.     IF h:=Open(fichier,1006)
  558.         Write(h,[ID_WVPR]:LONG,4)
  559.         sactnode:=list.head
  560.         WHILE sactnode
  561.             node:=sactnode
  562.             IF node.succ<>0
  563.                 Write(h,[ID_WVAC]:LONG,4)
  564.                 Write(h,[sactnode.exectype]:INT,2)
  565.                 Write(h,[sactnode.stack]:LONG,4)
  566.                 Write(h,[sactnode.priority]:INT,2)
  567.                 Write(h,node.name,EstrLen(node.name))
  568.                 Out(h,0)
  569.                 Write(h,sactnode.command,EstrLen(sactnode.command))
  570.                 Out(h,0)
  571.                 Write(h,sactnode.currentdir,EstrLen(sactnode.currentdir))
  572.                 Out(h,0)
  573.             ENDIF
  574.             sactnode:=node.succ
  575.         ENDWHILE
  576.         IF h THEN Close(h)
  577.     ENDIF
  578. ENDPROC
  579. PROC p_ReadPrefsFile(source) /*"p_ReadPrefsFile(source)"*/
  580.     DEF len,a,adr,buf,handle,flen=TRUE,pos
  581.     DEF chunk
  582.     DEF pv[256]:STRING
  583.     DEF node:PTR TO ln
  584.     DEF addact:PTR TO actionnode
  585.     DEF list:PTR TO lh,nn=NIL
  586.     IF (flen:=FileLength(source))=-1 THEN RETURN FALSE
  587.     IF (buf:=New(flen+1))=NIL THEN RETURN FALSE
  588.     IF (handle:=Open(source,1005))=NIL THEN RETURN FALSE
  589.     len:=Read(handle,buf,flen)
  590.     Close(handle)
  591.     IF len<1 THEN RETURN FALSE
  592.     adr:=buf
  593.     chunk:=Long(adr)
  594.     IF chunk<>ID_WVPR
  595.         Dispose(buf)
  596.         RETURN FALSE
  597.     ENDIF
  598.     p_RemoveActionList(mywvbase.adractionlist,FALSE)
  599.     FOR a:=0 TO len-1
  600.         pos:=adr++
  601.         chunk:=Long(pos)
  602.         SELECT chunk
  603.             CASE ID_WVAC
  604.                 pos:=pos+4
  605.                 node:=New(SIZEOF ln)
  606.                 addact:=New(SIZEOF actionnode)
  607.                 addact.exectype:=Int(pos)
  608.                 addact.stack:=Long(pos+2)
  609.                 addact.priority:=Int(pos+6)
  610.                 StringF(pv,'\s',pos+8)
  611.                 node.name:=String(EstrLen(pv))
  612.                 node.succ:=0
  613.                 StrCopy(node.name,pv,ALL)
  614.                 pos:=pos+8+EstrLen(pv)+1
  615.                 StringF(pv,'\s',pos)
  616.                 addact.command:=String(EstrLen(pv))
  617.                 StrCopy(addact.command,pv,ALL)
  618.                 pos:=pos+EstrLen(pv)+1
  619.                 StringF(pv,'\s',pos)
  620.                 addact.currentdir:=String(EstrLen(pv))
  621.                 StrCopy(addact.currentdir,pv,ALL)
  622.                 pos:=pos+EstrLen(pv)+1
  623.                 CopyMem(node,addact.node,SIZEOF ln)
  624.                 AddTail(mywvbase.adractionlist,addact.node)
  625.                 nn:=p_GetNumNode(mywvbase.adractionlist,addact.node)
  626.                 IF nn=0
  627.                     list:=mywvbase.adractionlist
  628.                     list.head:=addact.node
  629.                     node.pred:=0
  630.                 ENDIF
  631.                 IF node THEN Dispose(node)
  632.         ENDSELECT
  633.     ENDFOR
  634.     Dispose(buf)
  635.     RETURN TRUE
  636. ENDPROC
  637. /***************************/
  638. /* Main Proc               */
  639. /***************************/
  640. PROC main() HANDLE /*"main()"*/
  641.     DEF testmain
  642.     tattr:=['topaz.font',8,0,0]:textattr
  643.     StrCopy(defdir,'Sys:',ALL)
  644.     IF (testmain:=p_OpenLibraries())<>ER_NONE THEN Raise(testmain)
  645.     IF (testmain:=p_SetUpScreen())<>ER_NONE THEN Raise(testmain)
  646.     IF (testmain:=p_InitwpWindow())<>ER_NONE THEN Raise(testmain)
  647.     IF (testmain:=p_InitWVAPP())<>ER_NONE THEN Raise(testmain)
  648.     IF FileLength('Env:Whatview.prefs')<>-1 THEN p_ReadPrefsFile('env:whatview.prefs')
  649.     IF (testmain:=p_OpenwpWindow())<>ER_NONE THEN Raise(testmain)
  650.     REPEAT
  651.         p_LookAllMessage()
  652.     UNTIL reelquit=TRUE
  653.     Raise(ER_NONE)
  654. EXCEPT
  655.     p_RemwpWindow()
  656.     p_RemWVAPP()
  657.     p_SetDownScreen()
  658.     p_CloseLibraries()
  659.     SELECT exception
  660.         CASE ER_LOCKSCREEN; WriteF('Lock Screen Failed.')
  661.         CASE ER_VISUAL;     WriteF('Error Visual.')
  662.         CASE ER_CONTEXT;    WriteF('Error Context.')
  663.         CASE ER_MENUS;      WriteF('Error Menus.')
  664.         CASE ER_GADGET;     WriteF('Error Gadget.')
  665.         CASE ER_WINDOW;     WriteF('Error Window.')
  666.     ENDSELECT
  667. ENDPROC
  668.